{% load i18n log %}

{% get_admin_log 10 as admin_log for_user user %}

{% if admin_log %}
    <div id="content-related" class="lg:w-96">
        <div id="recent-actions-module" class="module bg-base-50 rounded-default p-3 dark:bg-base-800">
            <h2 class="mb-3 font-semibold text-base-900 dark:text-base-100">
                {% translate 'Recent actions' %}
            </h2>

            <ul class="actionlist">
                {% for entry in admin_log %}
                    <li class="{% if entry.is_addition %}addlink{% endif %}{% if entry.is_change %}changelink{% endif %}{% if entry.is_deletion %}deletelink{% endif %} border border-base-400/10 bg-white mb-3 p-3 rounded-default shadow-xs last:mb-0 dark:bg-base-900">
                        <div class="mb-3 overflow-hidden text-ellipsis whitespace-nowrap">
                            {% if entry.is_deletion or not entry.get_admin_url %}
                                {{ entry.object_repr }}
                            {% else %}
                                <a href="{{ entry.get_admin_url }}">{{ entry.object_repr }}</a>
                            {% endif %}
                        </div>

                        <div class="border-base-100 border-t flex pt-3 dark:border-base-800">
                            <div>
                                {% if entry.content_type %}
                                    {% filter capfirst %}{{ entry.content_type.name }}{% endfilter %}
                                {% else %}
                                    {% translate 'Unknown content' %}
                                {% endif %}
                            </div>

                            <div class="ml-auto">
                                {{ entry.action_time }}
                            </div>
                        </div>
                    </li>
                {% endfor %}
            </ul>
        </div>
    </div>
{% endif %}
